﻿<Window x:Class="LockCrypt.WinPromptPassword"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:loc="clr-namespace:LockCrypt"
    xmlns:lex="http://schemas.root-project.org/xaml/presentation"
    xmlns:conv="clr-namespace:LockCrypt.Converters"
    xmlns:l49="clr-namespace:Lime49;assembly=Lime49"
    Title="{lex:LocText LockCrypt.Core:Strings:OpenDatabase}" ResizeMode="NoResize" Style="{StaticResource {x:Type Window}}" Icon="/LockCrypt;component/Resources/LockCrypt.ico"
    MinHeight="100" MinWidth="300" MaxWidth="450" SizeToContent="WidthAndHeight"
    WindowStartupLocation="CenterOwner" Loaded="Window_Loaded" x:Name="root"
    l49:WindowService.EscapeClosesWindow="True"
    FocusManager.FocusedElement="{Binding ElementName=txtPassword}">
    <Window.CommandBindings>
        <CommandBinding Command="ApplicationCommands.Open" Executed="Open" />
        <CommandBinding Command="ApplicationCommands.Close" Executed="CloseWindow" />
        <!--CommandBinding Command="loc:LockCryptCommands.Browse" Executed="BrowseInputFile"/-->
    </Window.CommandBindings>
    <Window.Resources>
        <conv:StringEqualityToInvertedBooleanConverter x:Key="StringEqualityToInvertedBooleanConverter"/>
    </Window.Resources>
    <DockPanel LastChildFill="True">
        <StatusBar DockPanel.Dock="Bottom" MinHeight="24">
            <DockPanel LastChildFill="True">
                <TextBlock x:Name="lblStatus" DockPanel.Dock="Left" Visibility="Hidden" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" Margin="2" />
                <ProgressBar x:Name="prgStatus" DockPanel.Dock="Right" IsIndeterminate="True" MinWidth="40" Visibility="Hidden" />
            </DockPanel>
        </StatusBar>
        <Border DockPanel.Dock="Top" Background="{StaticResource LightBrush}" BorderBrush="{StaticResource SolidBorderBrush}" BorderThickness="0,0,0,1">
            <Grid>
                <Image Stretch="None" Source="pack://application:,,,/Resources/Images/banner_60.png" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="5,0,5,5"/>
                <TextBlock Text="{lex:LocText LockCrypt.Core:Strings:EnterPass}" FontSize="20" FontWeight="Bold" Margin="75,51,5,5" />
            </Grid>
        </Border>
        <Grid DockPanel.Dock="Top" Margin="6">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            
            <!--Label Grid.Row="1" Grid.Column="0" VerticalAlignment="Bottom" Content="{lex:LocText LockCrypt.Core:Strings:Filename}"/>
            <TextBox x:Name="txtFilename" Grid.Row="1" Grid.Column="1" TabIndex="1" Text="{Binding ElementName=root,Path=FileName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                     IsEnabled="{Binding ElementName=root,Path=CanEditFileName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
            <Button Grid.Row="1" Grid.Column="2" TabIndex="2" MinWidth="70" Command="loc:LockCryptCommands.Browse" HorizontalAlignment="Right" Content="{lex:LocText LockCrypt.Core:Strings:Browse}"
                    IsEnabled="{Binding ElementName=root,Path=CanEditFileName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/-->
            <loc:DatabaseSelector x:Name="dbSelector" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" ShowEncryption="False"
                                  IsEnabled="{Binding ElementName=root,Path=CanEditCredentials,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />

            <Label Grid.Row="2" Grid.Column="0" Content="{lex:LocText LockCrypt.Core:Strings:EncryptionAlgorithm}"/>
            <ComboBox Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" x:Name="cboEncryption" TabIndex="4" DisplayMemberPath="Value" SelectedValuePath="Key"
                      SelectedValue="{Binding ElementName=root,Path=EncryptionAlgorithm,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
            
            <Label Grid.Row="3" Grid.Column="0" Content="{lex:LocText LockCrypt.Core:Strings:Password}"/>
            <PasswordBox  Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" x:Name="txtPassword" TabIndex="5"
                          IsEnabled="{Binding SelectedValue,ElementName=cboEncryption,Converter={StaticResource StringEqualityToInvertedBooleanConverter},ConverterParameter='None'}"/>

            <StackPanel Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="3" Orientation="Horizontal" HorizontalAlignment="Right">
                <Button x:Name="btnSave" TabIndex="7" MinWidth="70" IsDefault="True" Command="ApplicationCommands.Open" Content="{lex:LocText LockCrypt.Core:Strings:OpenDatabase}" />
                <Button x:Name="btnCancel" TabIndex="8" MinWidth="70" IsCancel="True" Command="ApplicationCommands.Close" Content="{lex:LocText LockCrypt.Core:Strings:Cancel}"/>
            </StackPanel>
        </Grid>
    </DockPanel>
</Window>
